|
|
|
|
|
|
|
Figure 8.3
Program Bounce1 generates data when it is needed. |
|
|
|
|
|
|
|
|
arrays tell the program how to draw each ball. The variables xmax and ymax store the largest coordinates inside the picCourt control where the program draws the balls. |
|
|
|
|
|
|
|
|
For each frame, the program adds each ball's BallDx and BallDy values to its current position. It then checks that the ball lies completely within the picture box. If the ball does falls outside, the program moves it back into the picture box and reverses the sign of the corresponding BallDx or BallDy value. For example, if a ball crosses the left edge of the drawing area, the program sets BallDx(ball) = BallDx(ball). That reverses the ball's direction of movement and makes it appear to bounce off the left wall. |
|
|
|
 |
|
|
|
|
Private xmax As Integer
Private ymax As Integer
Private NumBalls As Integer
Private BallX() As Integer
Private BallY() As Integer
Private BallDx() As Integer
Private BallDy() As Integer
Private BallRadius() As Integer
Private BallColor() As Long
' Play the animation. Private Sub PlayImages(ByVal ms_per_frame As Long)
Dim ball As Integer
Dim next_time As Long
' Get the current time. next_time = GetTickCount()
' Start the animation. |
|
|
|
|
|